/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package canteen.sys.view;

import canteen.sys.model.entity.LoginMaster;

/**
 *
 * @author TNT
 */
public class OrderCheck extends javax.swing.JInternalFrame  {
    //implements ActionView<BillMaster>

//    HibernateDAOFactory hibernateDAOFactory = HibernateDAOFactory.getInstance();
//    DefaultTableModel modelTablePending;
//    DefaultTableModel modelTableProcessed;
//    DefaultTableModel modelTableProductList;
//    List<BillMaster> listBill;
//    EmployeeMaster em;
    /**
     * Creates new form OrderCheck
     */
    LoginMaster Lm;

    public OrderCheck(LoginMaster lm) {
        Lm = lm;
        initComponents();
//        modelTablePending = (DefaultTableModel) tbOrderPending.getModel();
//        modelTableProcessed = (DefaultTableModel) tbOrderProcessed.getModel();
//        modelTableProductList = (DefaultTableModel) tbProductList.getModel();
//        if (lm != null) {
//            em = hibernateDAOFactory.getEmployeeMasterDAO().findEmployeeByUserId(lm.getlId());
//            if (em != null) {
//                txtEmployee.setText(em.geteFName() + " " + em.geteLName() + " " + em.geteMName());
//                txtDepartment.setText(em.getDepartment().getDepartmentName());
//            }
//            listBill = hibernateDAOFactory.getBillMasterDAO()
//                    .findAllBillByDepartmentId(em.getDepartment().getDeptId());
//            showList(listBill);
//            listenerTableModelPending(modelTablePending);
//            listenerTableModelProcessed(modelTableProcessed);
//            listSelectionListenerPending();
//            listSelectionListenerProcessed();
////        LoginMaster lm = SessionFactoryClass.getInstance().getUser();
//        } else {
//            this.dispose();
//        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLayeredPane1 = new javax.swing.JLayeredPane();
        jScrollPane1 = new javax.swing.JScrollPane();
        tbOrderPending = new javax.swing.JTable();
        btrefresh = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jTextField1 = new javax.swing.JTextField();
        jButton2 = new javax.swing.JButton();
        jLayeredPane2 = new javax.swing.JLayeredPane();
        jScrollPane3 = new javax.swing.JScrollPane();
        tbOrderProcessed = new javax.swing.JTable();
        jLabel3 = new javax.swing.JLabel();
        cbStatus = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        jLayeredPane3 = new javax.swing.JLayeredPane();
        btPrint = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        tbProductList = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        txtOrderId = new javax.swing.JTextField();
        txtCreateDate = new javax.swing.JTextField();
        txtCouponNo = new javax.swing.JTextField();
        txtCouponDate = new javax.swing.JTextField();
        txtDepartment = new javax.swing.JTextField();
        txtEmployee = new javax.swing.JTextField();
        txtUserName = new javax.swing.JTextField();
        btApprove = new javax.swing.JButton();
        cbStatusChange = new javax.swing.JComboBox();

        setClosable(true);
        setTitle("Order check");

        tbOrderPending.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "ID", "User Name", "Create Date", "Status"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(tbOrderPending);
        tbOrderPending.getColumnModel().getColumn(0).setMaxWidth(50);
        tbOrderPending.getColumnModel().getColumn(3).setMaxWidth(100);

        jScrollPane1.setBounds(0, 30, 420, 240);
        jLayeredPane1.add(jScrollPane1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        btrefresh.setText("Order pending");
        btrefresh.setBounds(0, 0, 90, 20);
        jLayeredPane1.add(btrefresh, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jButton1.setText("Refresh");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jButton1.setBounds(90, 0, 80, 23);
        jLayeredPane1.add(jButton1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTextField1.setText("Enter User Name");
        jTextField1.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jTextField1FocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextField1FocusLost(evt);
            }
        });
        jTextField1.setBounds(180, 0, 130, 20);
        jLayeredPane1.add(jTextField1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jButton2.setText("Search");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        jButton2.setBounds(340, 0, 80, 23);
        jLayeredPane1.add(jButton2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        tbOrderProcessed.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "ID", "User Name", "Create Date", "Status"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane3.setViewportView(tbOrderProcessed);
        tbOrderProcessed.getColumnModel().getColumn(0).setMaxWidth(50);
        tbOrderProcessed.getColumnModel().getColumn(3).setMaxWidth(100);

        jScrollPane3.setBounds(0, 30, 460, 240);
        jLayeredPane2.add(jScrollPane3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel3.setText("Order Processed");
        jLabel3.setBounds(0, 0, 100, 20);
        jLayeredPane2.add(jLabel3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        cbStatus.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "all", "processed", "cancel" }));
        cbStatus.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbStatusActionPerformed(evt);
            }
        });
        cbStatus.setBounds(360, 0, 100, 20);
        jLayeredPane2.add(cbStatus, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel4.setText("Status");
        jLabel4.setBounds(311, 0, 40, 20);
        jLayeredPane2.add(jLabel4, javax.swing.JLayeredPane.DEFAULT_LAYER);

        btPrint.setText("Print");
        btPrint.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btPrintActionPerformed(evt);
            }
        });
        btPrint.setBounds(10, 0, 70, 23);
        jLayeredPane3.add(btPrint, javax.swing.JLayeredPane.DEFAULT_LAYER);

        tbProductList.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Product Name", "Product Type", "Qty", "Price"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane2.setViewportView(tbProductList);
        tbProductList.getColumnModel().getColumn(2).setMaxWidth(50);
        tbProductList.getColumnModel().getColumn(3).setMaxWidth(100);

        jScrollPane2.setBounds(430, 30, 460, 270);
        jLayeredPane3.add(jScrollPane2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel1.setText("Product List");
        jLabel1.setBounds(430, 10, 110, 14);
        jLayeredPane3.add(jLabel1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel5.setText("ID");
        jLabel5.setBounds(10, 40, 11, 14);
        jLayeredPane3.add(jLabel5, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel6.setText("User Name");
        jLabel6.setBounds(10, 70, 90, 20);
        jLayeredPane3.add(jLabel6, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel7.setText("Create Date");
        jLabel7.setBounds(10, 100, 90, 20);
        jLayeredPane3.add(jLabel7, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel8.setText("Coupon No");
        jLabel8.setBounds(10, 130, 90, 20);
        jLayeredPane3.add(jLabel8, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel9.setText("Coupon Date");
        jLabel9.setBounds(10, 160, 90, 20);
        jLayeredPane3.add(jLabel9, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel11.setText("Department");
        jLabel11.setBounds(220, 70, 70, 20);
        jLayeredPane3.add(jLabel11, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel12.setText("Employee");
        jLabel12.setBounds(220, 100, 60, 20);
        jLayeredPane3.add(jLabel12, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel13.setText("Status");
        jLabel13.setBounds(220, 130, 50, 20);
        jLayeredPane3.add(jLabel13, javax.swing.JLayeredPane.DEFAULT_LAYER);

        txtOrderId.setEnabled(false);
        txtOrderId.setBounds(40, 40, 60, 20);
        jLayeredPane3.add(txtOrderId, javax.swing.JLayeredPane.DEFAULT_LAYER);

        txtCreateDate.setEnabled(false);
        txtCreateDate.setBounds(100, 100, 110, 20);
        jLayeredPane3.add(txtCreateDate, javax.swing.JLayeredPane.DEFAULT_LAYER);

        txtCouponNo.setEnabled(false);
        txtCouponNo.setBounds(100, 130, 110, 20);
        jLayeredPane3.add(txtCouponNo, javax.swing.JLayeredPane.DEFAULT_LAYER);

        txtCouponDate.setEnabled(false);
        txtCouponDate.setBounds(100, 160, 110, 20);
        jLayeredPane3.add(txtCouponDate, javax.swing.JLayeredPane.DEFAULT_LAYER);

        txtDepartment.setEnabled(false);
        txtDepartment.setBounds(290, 70, 110, 20);
        jLayeredPane3.add(txtDepartment, javax.swing.JLayeredPane.DEFAULT_LAYER);

        txtEmployee.setEnabled(false);
        txtEmployee.setBounds(290, 100, 110, 20);
        jLayeredPane3.add(txtEmployee, javax.swing.JLayeredPane.DEFAULT_LAYER);

        txtUserName.setEnabled(false);
        txtUserName.setBounds(100, 70, 110, 20);
        jLayeredPane3.add(txtUserName, javax.swing.JLayeredPane.DEFAULT_LAYER);

        btApprove.setText("Approve");
        btApprove.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btApproveActionPerformed(evt);
            }
        });
        btApprove.setBounds(10, 250, 90, 23);
        jLayeredPane3.add(btApprove, javax.swing.JLayeredPane.DEFAULT_LAYER);

        cbStatusChange.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        cbStatusChange.setForeground(new java.awt.Color(255, 0, 0));
        cbStatusChange.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "pending", "processed", "cancel" }));
        cbStatusChange.setBounds(290, 130, 110, 20);
        jLayeredPane3.add(cbStatusChange, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
            .addGroup(layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 421, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLayeredPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 461, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addComponent(jLayeredPane3)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLayeredPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 274, Short.MAX_VALUE)
                    .addComponent(jLayeredPane1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLayeredPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 312, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     *
     * @param evt
     */
    private void btApproveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btApproveActionPerformed
        // TODO add your handling code here:
//        int indexTablePending = tbOrderPending.getSelectedRow();
//        int indexTableProcessed = tbOrderProcessed.getSelectedRow();
//        if (indexTablePending != -1) {
//            int indexStatusChange = cbStatusChange.getSelectedIndex();
//            if (indexStatusChange == 1) {
//                //-->processed
//                if (em != null) {
//                    if (JOptionPane.showConfirmDialog(this, "Are you sure?", "Warning",
//                            JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) {
//                        int indexList = listBill.indexOf(getObjectPending(indexTablePending));
//                        BillMaster billMaster = listBill.get(indexList);
//                        billMaster.setStatus(1);
//                        billMaster.setEmployeeMaster(em);
//                        //--move record-->tableOrderProcessed
//                        hibernateDAOFactory.getBillMasterDAO().makePersistent(listBill.get(indexList));
//                        deleteRowPending(indexTablePending);
//                        addRow(listBill.get(indexList), true);
//                        JOptionPane.showMessageDialog(null, "Approve Success!");
//                    }
//                } else {
//                    JOptionPane.showMessageDialog(this, "No employee Approved!");
//                }
//            } else if (cbStatusChange.getSelectedIndex() == 2) {
//                //-->cancel
//                int indexList = listBill.indexOf(getObjectPending(indexTablePending));
//                BillMaster billMaster = listBill.get(indexList);
//                billMaster.setStatus(2);
//                billMaster.setEmployeeMaster(em);
//                hibernateDAOFactory.getBillMasterDAO().makePersistent(listBill.get(indexList));
//                deleteRowPending(indexTablePending);
//                addRow(listBill.get(indexList), true);
//                JOptionPane.showMessageDialog(null, "Approve Success!");
//            }
//        } else if (tbOrderProcessed.getSelectedRow() != -1) {
//            int indexStatusChange = cbStatusChange.getSelectedIndex();
//            if (indexStatusChange == 1) {
//                //-->cancel-->processed
//                int indexList = listBill.indexOf(getObject(indexTableProcessed));
//                BillMaster billMaster = listBill.get(indexList);
//                billMaster.setStatus(1);
//                billMaster.setEmployeeMaster(em);
//                hibernateDAOFactory.getBillMasterDAO().makePersistent(listBill.get(indexList));
//                updateRow(listBill.get(indexList), indexTableProcessed);
//            } else if (indexStatusChange == 2) {
//                //-->processed-->cancel
//                int indexList = listBill.indexOf(getObject(indexTableProcessed));
//                BillMaster billMaster = listBill.get(indexList);
//                billMaster.setStatus(2);
//                billMaster.setEmployeeMaster(em);
//                hibernateDAOFactory.getBillMasterDAO().makePersistent(listBill.get(indexList));
//                updateRow(listBill.get(indexList), indexTableProcessed);
//            } else {
//                //-->cancel, processed-->pending
//                int indexList = listBill.indexOf(getObject(indexTableProcessed));
//                if (JOptionPane.showConfirmDialog(this, "Are you sure?", "Warning",
//                        JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) {
//                    BillMaster billMaster = listBill.get(indexList);
//                    billMaster.setStatus(0);
//                    billMaster.setEmployeeMaster(em);
//                    hibernateDAOFactory.getBillMasterDAO().makePersistent(listBill.get(indexList));
//                    deleteRow(indexTableProcessed);
//                    addRow(listBill.get(indexList), true);
//                    JOptionPane.showMessageDialog(null, "Approve Success!");
//                }
//            }
//        }

    }//GEN-LAST:event_btApproveActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
//        listBill.clear();
//        clearAllTable();
//        listBill = hibernateDAOFactory.getBillMasterDAO().findAll();
//        showList(listBill);
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
//        if (!jTextField1.getText().equals("Enter User Name")
//                && !jTextField1.getText().equals(" ")
//                && jTextField1.getText() != null) {
//            try {
//                LoginMaster user = hibernateDAOFactory.getLoginDAO().getUserByName(jTextField1.getText());
//                listBill.clear();
//                listBill = hibernateDAOFactory.getBillMasterDAO()
//                        .findAllBillSearchByUserId(user.getlId());
//                showList(listBill);
//            } catch (HibernateException ex) {
//                JOptionPane.showMessageDialog(this, "Error:\n" + ex.getMessage(), "Error",
//                        JOptionPane.ERROR_MESSAGE);
//            } catch (NullPointerException ex) {
//                JOptionPane.showMessageDialog(this, "User Name not exist!");
//            }
//        }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jTextField1FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField1FocusGained
        // TODO add your handling code here:
        if (jTextField1.getText().equals("Enter User Name")
                || jTextField1.getText().equals("")
                || jTextField1.getText() == null) {
            jTextField1.setText("");
        }
    }//GEN-LAST:event_jTextField1FocusGained

    private void jTextField1FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField1FocusLost
        // TODO add your handling code here:
        if (jTextField1.getText().equals("") || jTextField1.getText() == null) {
            jTextField1.setText("Enter User Name");
        }
    }//GEN-LAST:event_jTextField1FocusLost

    private void btPrintActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btPrintActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_btPrintActionPerformed

    private void cbStatusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbStatusActionPerformed
        // TODO add your handling code here:
//        modelTableProcessed.setDataVector(null, new Object[]{"ID", "User Name", "Create Date", "Status"});
//        int indexCBStatus = cbStatus.getSelectedIndex();
//        if (indexCBStatus != 0) {
//            for (BillMaster billMaster : listBill) {
//                if (indexCBStatus == 1 && billMaster.getStatus() == 1) {
//                    addRow(billMaster, isIcon);
//                } else if (indexCBStatus == 2 && billMaster.getStatus() == 2) {
//                    addRow(billMaster, isIcon);
//                }
//            }
//        } else {
//            showList(listBill);
//        }
    }//GEN-LAST:event_cbStatusActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btApprove;
    private javax.swing.JButton btPrint;
    private javax.swing.JLabel btrefresh;
    private javax.swing.JComboBox cbStatus;
    private javax.swing.JComboBox cbStatusChange;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLayeredPane jLayeredPane1;
    private javax.swing.JLayeredPane jLayeredPane2;
    private javax.swing.JLayeredPane jLayeredPane3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTable tbOrderPending;
    private javax.swing.JTable tbOrderProcessed;
    private javax.swing.JTable tbProductList;
    private javax.swing.JTextField txtCouponDate;
    private javax.swing.JTextField txtCouponNo;
    private javax.swing.JTextField txtCreateDate;
    private javax.swing.JTextField txtDepartment;
    private javax.swing.JTextField txtEmployee;
    private javax.swing.JTextField txtOrderId;
    private javax.swing.JTextField txtUserName;
    // End of variables declaration//GEN-END:variables

//    @Override
//    public void deleteRow(int index) {
//        modelTableProcessed.removeRow(index);
//    }
//
//    public void deleteRowPending(int index) {
//        modelTablePending.removeRow(index);
//    }
//
//    @Override
//    public void updateRow(BillMaster row, int index) {
//        if (row.getStatus() == 1) {
//            modelTableProcessed.setValueAt("processed", index, 3);
//            //listBill.get(listBill.size() - 1 - index).setStatus(row.getStatus());
//        } else if (row.getStatus() == 2) {
//            modelTableProcessed.setValueAt("cancel", index, 3);
//            //listBill.get(listBill.size() - 1 - index).setStatus(row.getStatus());
//        }
//    }
//
//    @Override
//    public void addRow(BillMaster row, boolean posion) {
//        if (row.getStatus() == 0) {
//            modelTablePending.insertRow(0, new Object[]{row.getbId(), row.getLoginMaster().getlName(),
//                        row.getbDate(), "pending"});
//        } else {
//            String statusString = "processed";
//            if (row.getStatus() == 2) {
//                statusString = "cancel";
//            }
//            modelTableProcessed.insertRow(0, new Object[]{row.getbId(), row.getLoginMaster().getlName(),
//                        row.getbDate(), statusString});
//        }
//    }
//
//    public void showListProduct(List<BillDetail> list) {
//
//        for (BillDetail billDetail : list) {
//            modelTableProductList.insertRow(0, new Object[]{billDetail.getItem().getItemName(),
//                        billDetail.getItem().getItemType().getItemTypeName(),
//                        billDetail.getItemQty(), "$" + billDetail.getItemRate()});
//        }
//    }
//
//    @Override
//    public final void showList(List<BillMaster> list) {
//        clearAllTable();
//        for (BillMaster item : list) {
//            if (item.getStatus() == 0) {
//                modelTablePending.insertRow(0, new Object[]{item.getbId(), item.getLoginMaster().getlName(),
//                            item.getbDate(), "pending"});
//            } else if (item.getStatus() == 1) {
//                modelTableProcessed.insertRow(0, new Object[]{item.getbId(), item.getLoginMaster().getlName(),
//                            item.getbDate(), "processed"});
//            } else {
//                modelTableProcessed.insertRow(0, new Object[]{item.getbId(), item.getLoginMaster().getlName(),
//                            item.getbDate(), "cancel"});
//            }
//        }
//    }
//
//    @Override
//    public void showDetail(BillMaster object) {
//        try {
//            txtOrderId.setText(object.getbId() + "");
//            txtUserName.setText(object.getLoginMaster().getlName());
//            txtCouponNo.setText(object.getCoupenNo() + "");
//            txtCouponDate.setText(object.getCoupenDate() + "");
//            txtCreateDate.setText(object.getbDate() + "");
//            txtDepartment.setText(object.getDepartment().getDepartmentName());
//            if (object.getEmployeeMaster() != null) {
//                txtEmployee.setText(object.getEmployeeMaster().geteFName() + " "
//                        + object.getEmployeeMaster().geteMName() + " "
//                        + object.getEmployeeMaster().geteLName());
//            }
//            cbStatusChange.setSelectedIndex(object.getStatus());
//            modelTableProductList.setDataVector(null, new Object[]{"Product Name", "Product Type", "Qty", "Rate"});
//            List<BillDetail> listProduct = hibernateDAOFactory.getBillDetailDAO().findAllBillDetailByBillId(object.getbId());
//            showListProduct(listProduct);
//        } catch (NullPointerException ex) {
//        }
//
//    }
//
//    @Override
//    public BillMaster getObject(int index) {
//        BillMaster billMaster = new BillMaster();
//        try {
//            for (BillMaster billMaster1 : listBill) {
//                if (billMaster1.getbId() == modelTableProcessed.getValueAt(index, 0)) {
//                    billMaster = billMaster1;
//                    break;
//                }
//            }
//        } catch (ArrayIndexOutOfBoundsException ex) {
//        }
//        return billMaster;
//    }
//
//    public BillMaster getObjectPending(int index) {
//        BillMaster billMaster = new BillMaster();
//        try {
//            for (BillMaster billMaster1 : listBill) {
//                if (billMaster1.getbId() == modelTablePending.getValueAt(index, 0)) {
//                    billMaster = billMaster1;
//                    break;
//                }
//            }
//        } catch (ArrayIndexOutOfBoundsException ex) {
//        }
//        return billMaster;
//    }
//
//    @Override
//    public void setObject(BillMaster object) {
//        throw new UnsupportedOperationException("Not supported yet.");
//    }
//
//    @Override
//    public boolean validObject(BillMaster object) {
//        throw new UnsupportedOperationException("Not supported yet.");
//    }
//
//    public final void listenerTableModelPending(DefaultTableModel model) {
//        model.addTableModelListener(new TableModelListener() {
//            @Override
//            public void tableChanged(TableModelEvent e) {
//                if (e.getType() == TableModelEvent.INSERT) {
//                    //JOptionPane.showMessageDialog(null, "Approve Success!");
//                } else if (e.getType() == TableModelEvent.UPDATE && e.getColumn() == 3) {
//                    JOptionPane.showMessageDialog(null, "Update Bill Success!");
//                }
//            }
//        });
//    }
//
//    public final void listenerTableModelProcessed(DefaultTableModel model) {
//        model.addTableModelListener(new TableModelListener() {
//            @Override
//            public void tableChanged(TableModelEvent e) {
//                if (e.getType() == TableModelEvent.INSERT) {
//                    //JOptionPane.showMessageDialog(null, "Approve Success!");
//                } else if (e.getType() == TableModelEvent.UPDATE && e.getColumn() == 3) {
//                    JOptionPane.showMessageDialog(null, "Update Bill Success!");
//                }
//            }
//        });
//    }
//
//    public final void listSelectionListenerPending() {
//        tbOrderPending.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
//            @Override
//            public void valueChanged(ListSelectionEvent e) {
//                int rowSelected = tbOrderPending.getSelectedRow();
//                showDetail(getObjectPending(rowSelected));
//            }
//        });
//    }
//
//    public final void listSelectionListenerProcessed() {
//        tbOrderProcessed.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
//            @Override
//            public void valueChanged(ListSelectionEvent e) {
//                int rowSelected = tbOrderProcessed.getSelectedRow();
//                showDetail(getObject(rowSelected));
//            }
//        });
//    }
//
//    private void clearAllTable() {
//        //        if (tbOrderPending.getRowCount() > 0 && tbOrderProcessed.getRowCount() > 0 && tbProductList.getRowCount() > 0) {
//        //            for (int i = 0; i < 4; i++) {
//        //                modelTablePending.removeRow(0);
//        //                modelTableProcessed.removeRow(0);
//        //                modelTableProductList.removeRow(0);
//        //            }
//        //        }
//        modelTablePending.setDataVector(null, new Object[]{"ID", "User Name", "Create Date", "Status"});
//        modelTableProcessed.setDataVector(null, new Object[]{"ID", "User Name", "Create Date", "Status"});
//        modelTableProductList.setDataVector(null, new Object[]{"Product Name", "Product Type", "Qty", "Price"});
//    }
}
